/*
    This file is part of Epoch <http://code.google.com/p/epoch/>.

    Copyright (C) 2011 Adam Meily <meily.adam@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/


#ifndef CHRONOSCONFIG_H
#define CHRONOSCONFIG_H

#include <QtCore/QString>
#include <QtCore/QDir>
#include <QtCore/QList>
#include <QtCore/QByteArray>
#include "DatabaseConfig.h"
#include "../Models/Revision.h"
#include "ShellConfig.h"

class ChronosConfig
{
public:
    //ChronosConfig(const QString& config);
    virtual ~ChronosConfig();
    
    const QDir& storageRoot() const;
    const QString& logFilePath() const;
    const QList<qint32> localAddresses() const;
    const QByteArray& key() const;
    const DatabaseConfig* dbConfig() const;
    const ShellConfig* shellConfig() const;
    
    bool isLocalAddress(quint32 addr) const;
    QFile deltaFile(const Revision& revision) const;
    QFile fullFile(const Revision& revision) const;
    QFile signatureFile(const Revision& revision) const;
    quint16 port() const;
    
    //bool isValid() const;
    
    static ChronosConfig* parse(const QString& configPath, QString* error);
    
protected:
    ChronosConfig();
    QFile baseFile(const Revision& revision, const QString& ext) const;
    
    
private:
    QDir m_storageRoot;
    QString m_logFilePath;
    QList<qint32> m_localAddresses;
    QByteArray m_key;
    quint16 m_port;
    DatabaseConfig *m_dbConfig;
    ShellConfig *m_shellConfig;
};

#endif // CHRONOSCONFIG_H
